package cn.smile.feign.hystrix;

import cn.smile.feign.Feign;
import cn.smile.pojo.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.sql.Timestamp;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: MaoSuyu
 * @User：John
 * @Date: 2019/5/29
 * @Time: 15:11
 * @Description: No Description
 */
@Component
public class FeignHystrix implements FallbackFactory<Feign> {
    @Override
    public Feign create(Throwable throwable) {
        return new Feign() {
            @Override
            public User getUser() {
                System.out.println("线程："+Thread.currentThread().getName());
                return new User("服务挂了",new Timestamp(System.currentTimeMillis()));
            }
            @Override
            public User getUser(User user) {
                return user=new User("服务挂掉了",new Timestamp(System.currentTimeMillis()));
            }
            @Override
            public String test() {
                return "服务挂了";
            }
            @Override
            public String hystrix() {
                return "服务挂了";
            }
            @Override
            public String getServer() {
                System.out.println("线程："+Thread.currentThread().getName());
                return "服务挂了";
            }
        };
    }
}
